Skip to content

Conversation

@llucax
Copy link
Contributor

@llucax llucax commented Sep 22, 2025

Introduce a new @unique decorator in the frequenz.core.enum module that ensures uniqueness among enum members, excluding those marked as deprecated. This allows deprecated members to serve as aliases for non-deprecated members without causing a ValueError.

Signed-off-by: Leandro Lucarella <[email protected]>
This commit introduces a new `@unique` decorator in the
`frequenz.core.enum` module that ensures uniqueness among enum members,
excluding those marked as deprecated. This allows deprecated members to
serve as aliases for non-deprecated members without causing a
`ValueError`.

Signed-off-by: Leandro Lucarella <[email protected]>
Copilot AI review requested due to automatic review settings September 22, 2025 13:16
@llucax llucax requested a review from a team as a code owner September 22, 2025 13:16
@llucax llucax requested a review from Marenz September 22, 2025 13:16
@llucax llucax self-assigned this Sep 22, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Introduces a new @unique decorator in the frequenz.core.enum module that enforces uniqueness only among non-deprecated enum members, allowing deprecated members to serve as aliases without raising ValueError.

Key Changes

  • Added unique decorator function that ignores deprecated members when checking for duplicate values
  • Comprehensive test suite covering various scenarios including deprecated aliases, duplicates, and edge cases
  • Updated release notes with examples demonstrating the new functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/frequenz/core/enum.py Implements the new unique decorator with logic to skip deprecated members during uniqueness validation
tests/test_enum.py Adds comprehensive test coverage for the unique decorator across multiple scenarios
RELEASE_NOTES.md Documents the new feature with usage examples and comparison to standard library behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:enum Affects the enum module labels Sep 22, 2025
@llucax llucax added type:enhancement New feature or enhancement visitble to users and removed part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:enum Affects the enum module labels Sep 22, 2025
@llucax llucax added this to the v1.2.0 milestone Sep 22, 2025
@llucax llucax added this pull request to the merge queue Sep 23, 2025
Merged via the queue into frequenz-floss:v1.x.x with commit e438ddd Sep 23, 2025
9 checks passed
@llucax llucax deleted the enum-unique branch September 23, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:enhancement New feature or enhancement visitble to users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants